package d0326;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestHushMap {
    public static void main(String[] args) {
        Map<String,Student> studentMap = new HashMap<>();
        Student s1 = new Student("肖战",23,89);
        Student s2 = new Student("邓紫棋",24,95);
        Student s3 = new Student("王一博",22,87);
        Student s4 = new Student("曲特",21,94);

        studentMap.put("xz",s1);
        studentMap.put("dzq",s2);
        studentMap.put("wyb",s3);
        studentMap.put("qt",s4);
        studentMap.put("GEM",s2);
        studentMap.put("GEM",s2);//重复的Key会被忽略

   /* System.out.println(studentMap.size());
    //Key不同，value可以相同
    Student x1 = studentMap.get("dzq");
    System.out.println(x1);*/

    /* Set<String> keys = studentMap.keySet();
        for(String str:
             keys){
            System.out.println(str +"------>"+ studentMap.get(str));
    }*/

        //key可以取得value,反过来不可以
    /*Collection<Student> values = studentMap.values();
    for (Student stu:
        values){
         System.out.println(stu);
        }*/

        Set<Map.Entry<String,Student>> entys= studentMap.entrySet();
        for(Map.Entry entry:
                entys){
            System.out.println(entry.getKey() +"-------->");
        }
    }
}